<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <SONIA ZRIBI>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <SONIA ZRIBI>
 */
class Application_Model_Datastat extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Iddatastat;

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_Valeur;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_ElementRapportIdelementRapport;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_ConfigColonneStatIdconfigColonneStat;


    /**
     * Parent relation fk_datastat_config_colonne_stat1
     *
     * @var Application_Model_ConfigColonneStat
     */
    protected $_ConfigColonneStat;

    /**
     * Parent relation fk_datastat_element_rapport1
     *
     * @var Application_Model_ElementRapport
     */
    protected $_ElementRapport;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'iddatastat'=>'Iddatastat',
            'valeur'=>'Valeur',
            'element_rapport_idelement_rapport'=>'ElementRapportIdelementRapport',
            'config_colonne_stat_idconfig_colonne_stat'=>'ConfigColonneStatIdconfigColonneStat',
        ));

        $this->setParentList(array(
            'FkDatastatConfigColonneStat1'=> array(
                    'property' => 'ConfigColonneStat',
                    'table_name' => 'ConfigColonneStat',
                ),
            'FkDatastatElementRapport1'=> array(
                    'property' => 'ElementRapport',
                    'table_name' => 'ElementRapport',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column iddatastat
     *
     * @param int $data
     * @return Application_Model_Datastat
     */
    public function setIddatastat($data)
    {
        $this->_Iddatastat = $data;
        return $this;
    }

    /**
     * Gets column iddatastat
     *
     * @return int
     */
    public function getIddatastat()
    {
        return $this->_Iddatastat;
    }

    /**
     * Sets column valeur
     *
     * @param string $data
     * @return Application_Model_Datastat
     */
    public function setValeur($data)
    {
        $this->_Valeur = $data;
        return $this;
    }

    /**
     * Gets column valeur
     *
     * @return string
     */
    public function getValeur()
    {
        return $this->_Valeur;
    }

    /**
     * Sets column element_rapport_idelement_rapport
     *
     * @param int $data
     * @return Application_Model_Datastat
     */
    public function setElementRapportIdelementRapport($data)
    {
        $this->_ElementRapportIdelementRapport = $data;
        return $this;
    }

    /**
     * Gets column element_rapport_idelement_rapport
     *
     * @return int
     */
    public function getElementRapportIdelementRapport()
    {
        return $this->_ElementRapportIdelementRapport;
    }

    /**
     * Sets column config_colonne_stat_idconfig_colonne_stat
     *
     * @param int $data
     * @return Application_Model_Datastat
     */
    public function setConfigColonneStatIdconfigColonneStat($data)
    {
        $this->_ConfigColonneStatIdconfigColonneStat = $data;
        return $this;
    }

    /**
     * Gets column config_colonne_stat_idconfig_colonne_stat
     *
     * @return int
     */
    public function getConfigColonneStatIdconfigColonneStat()
    {
        return $this->_ConfigColonneStatIdconfigColonneStat;
    }

    /**
     * Sets parent relation ConfigColonneStatIdconfigColonneStat
     *
     * @param Application_Model_ConfigColonneStat $data
     * @return Application_Model_Datastat
     */
    public function setConfigColonneStat(Application_Model_ConfigColonneStat $data)
    {
        $this->_ConfigColonneStat = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idconfig_colonne_stat'];
        }

        $this->setConfigColonneStatIdconfigColonneStat($primary_key);

        return $this;
    }

    /**
     * Gets parent ConfigColonneStatIdconfigColonneStat
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_ConfigColonneStat
     */
    public function getConfigColonneStat($load = true)
    {
        if ($this->_ConfigColonneStat === null && $load) {
            $this->getMapper()->loadRelated('FkDatastatConfigColonneStat1', $this);
        }

        return $this->_ConfigColonneStat;
    }

    /**
     * Sets parent relation ElementRapportIdelementRapport
     *
     * @param Application_Model_ElementRapport $data
     * @return Application_Model_Datastat
     */
    public function setElementRapport(Application_Model_ElementRapport $data)
    {
        $this->_ElementRapport = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idelement_rapport'];
        }

        $this->setElementRapportIdelementRapport($primary_key);

        return $this;
    }

    /**
     * Gets parent ElementRapportIdelementRapport
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_ElementRapport
     */
    public function getElementRapport($load = true)
    {
        if ($this->_ElementRapport === null && $load) {
            $this->getMapper()->loadRelated('FkDatastatElementRapport1', $this);
        }

        return $this->_ElementRapport;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Datastat
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Datastat());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Datastat::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIddatastat() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('iddatastat = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIddatastat()));
    }
}
